<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>
        <input type="text" v-model="num" placeholder="请输入1-100之间的整数：">
        <input type="button" value="猜一下" @click="guessNum()">
        <h1>结果是：{{info}}</h1>
    </div>
</body>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
        let gnum = parseInt(Math.random()*100) + 1;

        let v = new Vue({
        el:"body>div",
        data:{
            info:"",
            num: ""
        },
        methods: {
            guessNum(){
                if (v.num > gnum){
                    v.info = "猜大了！"
                }else if(v.num < gnum){
                    v.info = "猜小了~"
                }else {
                    v.info = "猜对了~"
                }
            }
        }
    })
</script>

</html>
